﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using condortravel.operaciones.core.DataModel;
using System.Data.Linq;

namespace condortravel.operaciones.persistence.operacionesImpl
{
   public class CiudadDAOImpl : condortravel.operaciones.persistence.Impl.GenericDAO<Tb_Ciudad, int>
   {

       #region Custom Methods

       public IList<Tb_Ciudad> getByPais(int pais)
       {

           using (ImpersonationHelper imp = new ImpersonationHelper(this.Impersonation.User, this.Impersonation.Domain, this.Impersonation.Password))
           {
               if (IsImpersonate)
               {
                   if (!imp.ImpersonateUser())
                   {
                       throw new Exception("The Impersonate has failed");
                   }

               }
               using (DataContext dataContext = new DataContext(this.ConnectionString))
               {
                   return (from p in dataContext.GetTable<Tb_Ciudad>()
                           where p.pais_ID==pais
                           select p).ToList<Tb_Ciudad>();
               }
           }
       }

       #endregion

       #region CRUD
       public override Tb_Ciudad update(Tb_Ciudad entity)
        {
            throw new NotImplementedException();
        }

        public override Tb_Ciudad getByID(int id)
        {
            throw new NotImplementedException();
        }

        public override void delete(int pk)
        {
            throw new NotImplementedException();
        }

       #endregion
   }
}
